/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.asistente.entidades;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Wizard
 */
@Entity
@Table(name = "hd_clasificacion_media")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "HdClasificacionMedia.findAll", query = "SELECT h FROM HdClasificacionMedia h"),
    @NamedQuery(name = "HdClasificacionMedia.findByCodNivel2", query = "SELECT h FROM HdClasificacionMedia h WHERE h.codNivel2 = :codNivel2"),
    @NamedQuery(name = "HdClasificacionMedia.findByDesNivel2", query = "SELECT h FROM HdClasificacionMedia h WHERE h.desNivel2 = :desNivel2"),
    @NamedQuery(name = "HdClasificacionMedia.findByIndEstadoNivel2", query = "SELECT h FROM HdClasificacionMedia h WHERE h.indEstadoNivel2 = :indEstadoNivel2")})
public class HdClasificacionMedia implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "COD_NIVEL2")
    private Integer codNivel2;
    @Size(max = 50)
    @Column(name = "DES_NIVEL2")
    private String desNivel2;
    @Column(name = "IND_ESTADO_NIVEL2")
    private Character indEstadoNivel2;
    @JoinColumn(name = "COD_NIVEL1", referencedColumnName = "COD_NIVEL1")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private HdClasificacionMayor codNivel1;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "codNivel2", fetch = FetchType.LAZY)
    private Collection<HdClasificacionBaja> hdClasificacionBajaCollection;

    public HdClasificacionMedia() {
    }

    public HdClasificacionMedia(Integer codNivel2) {
        this.codNivel2 = codNivel2;
    }

    public Integer getCodNivel2() {
        return codNivel2;
    }

    public void setCodNivel2(Integer codNivel2) {
        this.codNivel2 = codNivel2;
    }

    public String getDesNivel2() {
        return desNivel2;
    }

    public void setDesNivel2(String desNivel2) {
        this.desNivel2 = desNivel2;
    }

    public Character getIndEstadoNivel2() {
        return indEstadoNivel2;
    }

    public void setIndEstadoNivel2(Character indEstadoNivel2) {
        this.indEstadoNivel2 = indEstadoNivel2;
    }

    public HdClasificacionMayor getCodNivel1() {
        return codNivel1;
    }

    public void setCodNivel1(HdClasificacionMayor codNivel1) {
        this.codNivel1 = codNivel1;
    }

    @XmlTransient
    public Collection<HdClasificacionBaja> getHdClasificacionBajaCollection() {
        return hdClasificacionBajaCollection;
    }

    public void setHdClasificacionBajaCollection(Collection<HdClasificacionBaja> hdClasificacionBajaCollection) {
        this.hdClasificacionBajaCollection = hdClasificacionBajaCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (codNivel2 != null ? codNivel2.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof HdClasificacionMedia)) {
            return false;
        }
        HdClasificacionMedia other = (HdClasificacionMedia) object;
        if ((this.codNivel2 == null && other.codNivel2 != null) || (this.codNivel2 != null && !this.codNivel2.equals(other.codNivel2))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.asistente.DAO.HdClasificacionMedia[ codNivel2=" + codNivel2 + " ]";
    }
    
}
